package com.itrip.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itrip.dao.ItripHotelMapper;
import com.itrip.entity.ItripAreaDic;
import com.itrip.entity.ItripHotel;
import com.itrip.entity.ItripLabelDic;
import com.itrip.service.ItripAreaDicService;
import com.itrip.service.ItripHotelService;
import com.itrip.service.ItripLabelDicService;
import com.itrip.vo.hotel.HotelVideoDescVO;
import com.itrip.vo.hotel.ItripSearchDetailsHotelVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@Service
public class ItripHotelServiceImpl extends ServiceImpl<ItripHotelMapper, ItripHotel> implements ItripHotelService{

 private static final Logger LOGGER = LoggerFactory.getLogger(ItripHotelServiceImpl.class);
 @Resource
 private ItripAreaDicService itripAreaDicService;
 @Resource
 private ItripLabelDicService itripLabelDicService;

 @Override
 public HotelVideoDescVO chaxunjuedian(Long id) {
  HotelVideoDescVO hotelVideoDescVO=new HotelVideoDescVO();

  //查询酒店商圈
  List<ItripAreaDic>  list=itripAreaDicService.chaxunjuedian(id);
  List<String> list1=new ArrayList<>();
  for (ItripAreaDic itripAreaDic : list) {
   list1.add(itripAreaDic.getName());
  }
  //查询酒店类型
  List<ItripLabelDic> listLabal=itripLabelDicService.searchDetailsHote(id);
  List<String>  list2=new ArrayList<>();
  for (ItripLabelDic itripLabelDic : listLabal) {
   list2.add(itripLabelDic.getName());
  }
  hotelVideoDescVO.setTradingAreaNameList(list1);
  hotelVideoDescVO.setHotelFeatureList(list2);
  ItripHotelMapper hotelMapper=getBaseMapper();
  hotelVideoDescVO.setHotelName(hotelMapper.selectById(id).getHotelName());
  return hotelVideoDescVO;
 }
 @Override
 public List<ItripSearchDetailsHotelVO> itrip(Long cityid) {
  List<ItripSearchDetailsHotelVO> listSearch=new ArrayList<>();
  ItripSearchDetailsHotelVO SearchDetailsHotelVO=new ItripSearchDetailsHotelVO();
  ItripHotelMapper hotelMapper=getBaseMapper();
  SearchDetailsHotelVO.setName("酒店介绍");
  SearchDetailsHotelVO.setDescription(hotelMapper.selectById(cityid).getDetails());
  listSearch.add(SearchDetailsHotelVO);
  List<ItripLabelDic> listLabel=itripLabelDicService.searchDetailsHote(cityid);
  for (ItripLabelDic itripLabelDic : listLabel) {
   ItripSearchDetailsHotelVO SearchDetailsHotelVO1=new ItripSearchDetailsHotelVO();
   SearchDetailsHotelVO1.setName(itripLabelDic.getName());
   SearchDetailsHotelVO1.setDescription(itripLabelDic.getDescription());
   listSearch.add(SearchDetailsHotelVO1);
  }
  return listSearch;
 }

 @Override
 public ItripHotel chaxunjuediani(Long cityid) {
  ItripHotelMapper il=getBaseMapper();
  QueryWrapper<ItripHotel> qw= Wrappers.query();
  return il.selectById(cityid);
 }


}
